package com.xujiang.common.util;

import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;

/**
 * @author xujiang
 * @version 2017-05-11 15:21
 */
public class Utils {

    /**
     * 得到app的版本
     * @param context
     * @return
     * @throws Exception
     */
    public static String getAppVersion(Context context) throws Exception {
        PackageManager packageManager = context.getPackageManager();
        PackageInfo packInfo = packageManager.getPackageInfo(context.getPackageName(),0);
        String versionName = packInfo.versionName;
        return versionName;
    }

    /**
     * 获取系统版本
     * @return
     */
    public static int getSystemVersion(){
        int version= android.os.Build.VERSION.SDK_INT;
        return version;
    }
}
